<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
  "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    
    <title>collectd - Send statistics over UDP to collectd servers &mdash; collectd v1.0 documentation</title>
    <link rel="stylesheet" href="_static/default.css" type="text/css" />
    <link rel="stylesheet" href="_static/pygments.css" type="text/css" />
    <script type="text/javascript">
      var DOCUMENTATION_OPTIONS = {
        URL_ROOT:    '#',
        VERSION:     '1.0',
        COLLAPSE_MODINDEX: false,
        FILE_SUFFIX: '.html',
        HAS_SOURCE:  true
      };
    </script>
    <script type="text/javascript" src="_static/jquery.js"></script>
    <script type="text/javascript" src="_static/doctools.js"></script>
    <link rel="top" title="collectd v1.0 documentation" href="#" /> 
  </head>
  <body>
    <div class="related">
      <h3>Navigation</h3>
      <ul>
        <li class="right" style="margin-right: 10px">
          <a href="genindex.html" title="General Index"
             accesskey="I">index</a></li>
        <li><a href="#">collectd v1.0 documentation</a> &raquo;</li> 
      </ul>
    </div>  

    <div class="document">
      <div class="documentwrapper">
        <div class="bodywrapper">
          <div class="body">
            
  <ul class="simple">
</ul>
<div class="section" id="collectd-send-statistics-over-udp-to-collectd-servers">
<h1>collectd - Send statistics over UDP to collectd servers<a class="headerlink" href="#collectd-send-statistics-over-udp-to-collectd-servers" title="Permalink to this headline">¶</a></h1>
<p>This module implements the
<a class="reference external" href="http://collectd.org/wiki/index.php/Binary_protocol">binary protocol</a>
used by the
<a class="reference external" href="http://collectd.org/wiki/index.php/Plugin:Network">Network plugin</a>
to let you send arbitrary numeric data to collectd servers.  Other than turning
on the Network plugin on the destination collectd server, no configuration is
needed.</p>
<p>Although you can configure your collectd server to do anything with your
statistics, most people use the
<a class="reference external" href="http://collectd.org/wiki/index.php/Plugin:RRDtool">RRDtool plugin</a>
to efficiently store large quantities of data.  Therefore, this tutorial
will discuss the output files generated by the RRDtool plugin, even though
this module sends destination-agnostic statistics messages to your collectd
server.</p>
<p>Here&#8217;s an example of sending statistics:</p>
<div class="highlight-python"><div class="highlight"><pre><span class="kn">import</span> <span class="nn">time</span><span class="o">,</span> <span class="nn">random</span>

<span class="kn">import</span> <span class="nn">collectd</span>

<span class="n">collectd</span><span class="o">.</span><span class="n">start_threads</span><span class="p">()</span>
<span class="n">conn</span> <span class="o">=</span> <span class="n">collectd</span><span class="o">.</span><span class="n">Connection</span><span class="p">()</span>

<span class="k">while</span> <span class="bp">True</span><span class="p">:</span>
    <span class="n">conn</span><span class="o">.</span><span class="n">some_category</span><span class="o">.</span><span class="n">record</span><span class="p">(</span><span class="n">some_counter</span> <span class="o">=</span> <span class="mi">1</span><span class="p">,</span> <span class="n">another_stat</span> <span class="o">=</span> <span class="n">random</span><span class="o">.</span><span class="n">random</span><span class="p">())</span>
    <span class="k">if</span> <span class="n">random</span><span class="o">.</span><span class="n">randrange</span><span class="p">(</span><span class="mi">2</span><span class="p">):</span>
        <span class="n">conn</span><span class="o">.</span><span class="n">coin_stats</span><span class="o">.</span><span class="n">record</span><span class="p">(</span><span class="s">&quot;heads&quot;</span><span class="p">,</span> <span class="n">flips</span> <span class="o">=</span> <span class="mi">1</span><span class="p">)</span>
    <span class="k">else</span><span class="p">:</span>
        <span class="n">conn</span><span class="o">.</span><span class="n">coin_stats</span><span class="o">.</span><span class="n">record</span><span class="p">(</span><span class="s">&quot;tails&quot;</span><span class="p">,</span> <span class="n">flips</span> <span class="o">=</span> <span class="mi">1</span><span class="p">)</span>
    
    <span class="n">time</span><span class="o">.</span><span class="n">sleep</span><span class="p">(</span><span class="n">random</span><span class="o">.</span><span class="n">randint</span><span class="p">(</span><span class="mi">1</span><span class="p">,</span> <span class="mi">4</span><span class="p">))</span>
</pre></div>
</div>
<p>If you run this script (which is <tt class="docutils literal"><span class="pre">examples/basic.py</span></tt> in your source package)
then your collectd server will create an RRD file for each statistic you are
tracking.  These files are typically stored under one central location on the
filesysem, such as <tt class="docutils literal"><span class="pre">/var/lib/collectd/rrd</span></tt> and organized by the hostname of
where the statistics came from and the name of the plugin that generated them.</p>
<p>This module identifies itself with the plugin name <tt class="docutils literal"><span class="pre">any</span></tt>, so if you ran
the above script, it would create a <tt class="docutils literal"><span class="pre">localhost/any</span></tt> directory with the
following files:</p>
<ul class="simple">
<li><tt class="docutils literal"><span class="pre">gauge-some_category-another_stat.rrd</span></tt></li>
<li><tt class="docutils literal"><span class="pre">gauge-some_category-some_counter.rrd</span></tt></li>
<li><tt class="docutils literal"><span class="pre">gauge-coin_stats-heads-flips.rrd</span></tt></li>
<li><tt class="docutils literal"><span class="pre">gauge-coin_stats-tails-flips.rrd</span></tt></li>
<li><tt class="docutils literal"><span class="pre">gauge-coin_stats-flips.rrd</span></tt> (contains the sum of heads and tails flips)</li>
</ul>
<p>Each call to <tt class="docutils literal"><span class="pre">record()</span></tt> increments the statistics you provide.  Periodically
the sums of these statistics are sent to the collectd server and then reset.
Therefore, if you displayed a graph of one of these statistics files, each
data point on the graph would represent the sum of all <tt class="docutils literal"><span class="pre">record()</span></tt> values
over that time increment.</p>
</div>
<div class="section" id="installation">
<h1>Installation<a class="headerlink" href="#installation" title="Permalink to this headline">¶</a></h1>
<p>This module is free for use under the BSD license.  It requires Python 2.6 and
will presumably work with Python 2.7, although this hasn&#8217;t been tested.  It has
no other dependencies.</p>
<p>You may <a class="reference external" href="http://collectd.googlecode.com/files/collectd-1.0.tar.gz">click here</a> to
download the collectd module.
You may also run <tt class="docutils literal"><span class="pre">easy_install</span> <span class="pre">collectd</span></tt> if you have
<a class="reference external" href="http://peak.telecommunity.com/DevCenter/EasyInstall">EasyInstall</a> on your
system.  The project page for collectd in the Cheese Shop (aka the Python
Package Index or PyPI)
<a class="reference external" href="http://pypi.python.org/pypi/collectd/">may be found here</a>.</p>
<p>You may also check out the development version of collectd with this command:</p>
<p><tt class="docutils literal"><span class="pre">hg</span> <span class="pre">clone</span> <span class="pre">https://collectd.googlecode.com/hg/</span> <span class="pre">collectd</span></tt></p>
</div>
<div class="section" id="functions-and-classes">
<h1>Functions and Classes<a class="headerlink" href="#functions-and-classes" title="Permalink to this headline">¶</a></h1>
<dl class="function">
<dt id="start_threads">
<tt class="descname">start_threads</tt><big>(</big><big>)</big><a class="headerlink" href="#start_threads" title="Permalink to this definition">¶</a></dt>
<dd><p>This function starts two daemon threads.  The first takes snapshots of your
counters and resets them periodically.  The other serializes the statistics
into protocol messages understood by the collectd Network plugin and sends
them in appropriately-sized UDP packets.</p>
<p>You must call this function when your program starts, or else this module
will never actually send any data to any collectd servers.  Calling this
function more than once throws an exception.</p>
</dd></dl>

<dl class="class">
<dt id="Connection">
<em class="property">class </em><tt class="descname">Connection</tt><big>(</big><em>hostname = socket.gethostname()</em>, <em>collectd_host = &quot;localhost&quot;</em>, <em>collectd_port = 25826</em>, <em>plugin_inst = &quot;&quot;</em><big>)</big><a class="headerlink" href="#Connection" title="Permalink to this definition">¶</a></dt>
<dd><p>Connection objects may be instantiated with 4 optional arguments:</p>
<ul class="simple">
<li><tt class="docutils literal"><span class="pre">hostname</span></tt>: the hostname you use to identify yourself to the collectd server; if omitted, this defaults to the result of <tt class="docutils literal"><span class="pre">socket.gethostname()</span></tt></li>
<li><tt class="docutils literal"><span class="pre">collectd_host</span></tt>: the hostname or ip address of the collectd server to which we will send statistics</li>
<li><tt class="docutils literal"><span class="pre">collectd_port</span></tt>: the port to which you will send statistics messages</li>
<li><tt class="docutils literal"><span class="pre">plugin_inst</span></tt>: the plugin instance name which will be sent to the collectd server; this mostly affects the directory name used by the collectd rrdtool plugin</li>
</ul>
<p>Connection objects with identical parameters are singletons; in other
words, <tt class="docutils literal"><span class="pre">Connection(&quot;foo&quot;)</span> <span class="pre">is</span> <span class="pre">Connection(&quot;foo&quot;)</span></tt> but
<tt class="docutils literal"><span class="pre">Connection(&quot;foo&quot;)</span> <span class="pre">is</span> <span class="pre">not</span> <span class="pre">Connection(&quot;bar&quot;)</span></tt>.</p>
<dl class="method">
<dt id="Connection.__getattr__">
<tt class="descname">__getattr__</tt><big>(</big><em>name</em><big>)</big><a class="headerlink" href="#Connection.__getattr__" title="Permalink to this definition">¶</a></dt>
<dd><p>Statistics are recorded through <tt class="docutils literal"><span class="pre">Counter</span></tt> objects, which are
dynamically generated by accessing fields on <tt class="docutils literal"><span class="pre">Connection</span></tt> instances.
So saying <tt class="docutils literal"><span class="pre">conn.foo</span></tt> creates a <tt class="docutils literal"><span class="pre">Counter</span></tt> object.</p>
<p>These objects are distinct but cached, so <tt class="docutils literal"><span class="pre">conn.foo</span> <span class="pre">is</span> <span class="pre">conn.foo</span></tt> but
<tt class="docutils literal"><span class="pre">conn.foo</span> <span class="pre">is</span> <span class="pre">not</span> <span class="pre">conn.bar</span></tt>.</p>
</dd></dl>

</dd></dl>

<dl class="class">
<dt id="Counter">
<em class="property">class </em><tt class="descname">Counter</tt><big>(</big><em>category</em><big>)</big><a class="headerlink" href="#Counter" title="Permalink to this definition">¶</a></dt>
<dd><p>You shouldn&#8217;t directly instantiate this class; instead <tt class="docutils literal"><span class="pre">Counter</span></tt> objects
are automatically created by accessing attributes of <tt class="docutils literal"><span class="pre">Connection</span></tt> objects
such that <tt class="docutils literal"><span class="pre">conn.foo</span></tt> will cache and return <tt class="docutils literal"><span class="pre">Counter(&quot;foo&quot;)</span></tt>.</p>
<p>Both of the following methods swallow and log all possible exceptions, so
you never need to worry about an error being thrown by calls to either of
these methods.  These functions are also synchronized, so you can safely
call them simultaneously from different threads.</p>
<dl class="method">
<dt id="Counter.record">
<tt class="descname">record</tt><big>(</big><em>*specific</em>, <em>**stats</em><big>)</big><a class="headerlink" href="#Counter.record" title="Permalink to this definition">¶</a></dt>
<dd><p>Each keyword argument to this method is interpreted as a statistic,
whose name is the argument name, and whose value is incrementd by
the argument value.</p>
<p>You may pass one or more string identifiers as positional arguments
to this method.  If you do so, then separate statistic counts will
be maintained for this identifier.  These counts are always added
to the base count for each statistic.</p>
<p>For example, if you ran the following code</p>
<div class="highlight-python"><div class="highlight"><pre><span class="n">conn</span> <span class="o">=</span> <span class="n">collectd</span><span class="o">.</span><span class="n">Connection</span><span class="p">()</span>
<span class="n">conn</span><span class="o">.</span><span class="n">example</span><span class="o">.</span><span class="n">record</span><span class="p">(</span><span class="n">baz</span> <span class="o">=</span> <span class="mi">1</span><span class="p">)</span>
<span class="n">conn</span><span class="o">.</span><span class="n">example</span><span class="o">.</span><span class="n">record</span><span class="p">(</span><span class="s">&quot;foo&quot;</span><span class="p">,</span> <span class="n">baz</span> <span class="o">=</span> <span class="mi">2</span><span class="p">)</span>
<span class="n">conn</span><span class="o">.</span><span class="n">example</span><span class="o">.</span><span class="n">record</span><span class="p">(</span><span class="s">&quot;bar&quot;</span><span class="p">,</span> <span class="n">baz</span> <span class="o">=</span> <span class="mi">3</span><span class="p">)</span>
</pre></div>
</div>
<p>and then statistics were sent to the collectd server, it would result
in the following files:</p>
<ul class="simple">
<li><tt class="docutils literal"><span class="pre">gauge-example-baz.rrd</span></tt> (with a value of 6 for this time increment)</li>
<li><tt class="docutils literal"><span class="pre">gauge-example-foo-baz.rrd</span></tt> (with a value of 2 for this time increment)</li>
<li><tt class="docutils literal"><span class="pre">gauge-example-bar-baz.rrd</span></tt> (with a value of 3 for this time increment)</li>
</ul>
</dd></dl>

<dl class="method">
<dt id="Counter.set_exact">
<tt class="descname">set_exact</tt><big>(</big><em>**stats</em><big>)</big><a class="headerlink" href="#Counter.set_exact" title="Permalink to this definition">¶</a></dt>
<dd>Each keyword argument to this method is interpreted as a statistic,
whose name is the argument name, and whose value is set to the exact
value of the argument.  Use this method when you have values which you
wish to update to a specific value rather than increment.</dd></dl>

</dd></dl>

<div class="admonition warning">
<p class="first admonition-title">Warning</p>
<p>All names are sanitized to contain only alphanumeric characters separated
by underscores.  In other words, if you did something like</p>
<div class="highlight-python"><div class="highlight"><pre><span class="n">conn</span> <span class="o">=</span> <span class="n">collectd</span><span class="o">.</span><span class="n">Connection</span><span class="p">()</span>
<span class="n">counter</span> <span class="o">=</span> <span class="nb">getattr</span><span class="p">(</span><span class="n">conn</span><span class="p">,</span> <span class="s">&quot;^@#@foo%$&amp;&amp;*&quot;</span><span class="p">)</span>
<span class="n">stat</span> <span class="o">=</span> <span class="p">{</span><span class="s">&quot;*()#@spam!@$^&amp;*&quot;</span><span class="p">:</span> <span class="mi">1</span><span class="p">}</span>
<span class="n">counter</span><span class="o">.</span><span class="n">record</span><span class="p">(</span><span class="s">&quot;()#@bar&amp;*()baz$^_+&quot;</span><span class="p">,</span> <span class="o">**</span><span class="n">stat</span><span class="p">)</span>
</pre></div>
</div>
<p>then the resulting files would be named <tt class="docutils literal"><span class="pre">gauge-foo-spam.rrd</span></tt> and
<tt class="docutils literal"><span class="pre">gauge-foo-bar_baz-spam.rrd</span></tt>. Although this behavior is generally
desirable, it could lead to your statistics becoming merged.  For example,
the <tt class="docutils literal"><span class="pre">foo-bar</span></tt> and <tt class="docutils literal"><span class="pre">foo/bar</span></tt> statistics in the following code would be
combined into a single <tt class="docutils literal"><span class="pre">foo_bar</span></tt> statistic:</p>
<div class="last highlight-python"><div class="highlight"><pre><span class="n">conn</span> <span class="o">=</span> <span class="n">collectd</span><span class="o">.</span><span class="n">Connection</span><span class="p">()</span>
<span class="n">conn</span><span class="o">.</span><span class="n">foo</span><span class="o">.</span><span class="n">record</span><span class="p">(</span><span class="s">&quot;foo-bar&quot;</span><span class="p">,</span> <span class="n">baz</span> <span class="o">=</span> <span class="mi">2</span><span class="p">)</span>
<span class="n">conn</span><span class="o">.</span><span class="n">foo</span><span class="o">.</span><span class="n">record</span><span class="p">(</span><span class="s">&quot;foo/bar&quot;</span><span class="p">,</span> <span class="n">baz</span> <span class="o">=</span> <span class="mi">3</span><span class="p">)</span>
</pre></div>
</div>
</div>
</div>
<div class="section" id="logging">
<h1>Logging<a class="headerlink" href="#logging" title="Permalink to this headline">¶</a></h1>
<p>As mentioned above, collectd swallows exceptions so that you never have to
worry about calling a function from this module and triggering an exception.
However, any exceptions which do occur are logged using the
<a class="reference external" href="http://docs.python.org/library/logging.html">logging</a> module from the
standard library, specifically to the <cite>collectd</cite> logger.  No other logging
is performed.</p>
<p>However, this module defines no handlers for the <cite>collectd</cite> logger, so by
default nothing is done with any of these log messages.</p>
</div>
<div class="section" id="a-more-complex-example">
<h1>A More Complex Example<a class="headerlink" href="#a-more-complex-example" title="Permalink to this headline">¶</a></h1>
<p>The following code is available in the <tt class="docutils literal"><span class="pre">examples/primes.py</span></tt> file in your
source distribution:</p>
<div class="highlight-python"><div class="highlight"><pre><span class="kn">import</span> <span class="nn">time</span>
<span class="kn">from</span> <span class="nn">Queue</span> <span class="kn">import</span> <span class="n">Queue</span>
<span class="kn">from</span> <span class="nn">threading</span> <span class="kn">import</span> <span class="n">Thread</span>
<span class="kn">from</span> <span class="nn">random</span> <span class="kn">import</span> <span class="n">normalvariate</span>

<span class="kn">import</span> <span class="nn">collectd</span>

<span class="n">numbers</span> <span class="o">=</span> <span class="n">Queue</span><span class="p">()</span>
<span class="n">conn</span> <span class="o">=</span> <span class="n">collectd</span><span class="o">.</span><span class="n">Connection</span><span class="p">()</span>

<span class="k">def</span> <span class="nf">is_prime</span><span class="p">(</span><span class="n">n</span><span class="p">):</span>
    <span class="k">for</span> <span class="n">i</span> <span class="ow">in</span> <span class="nb">xrange</span><span class="p">(</span><span class="mi">2</span><span class="p">,</span> <span class="n">n</span><span class="p">):</span>
        <span class="k">if</span> <span class="n">n</span> <span class="o">%</span> <span class="n">i</span> <span class="o">==</span> <span class="mi">0</span><span class="p">:</span>
            <span class="k">return</span> <span class="bp">False</span>
    <span class="k">return</span> <span class="bp">True</span>

<span class="k">def</span> <span class="nf">watch_queue</span><span class="p">():</span>
    <span class="k">while</span> <span class="bp">True</span><span class="p">:</span>
        <span class="n">conn</span><span class="o">.</span><span class="n">queue</span><span class="o">.</span><span class="n">set_exact</span><span class="p">(</span><span class="n">size</span> <span class="o">=</span> <span class="n">numbers</span><span class="o">.</span><span class="n">qsize</span><span class="p">())</span>
        <span class="n">time</span><span class="o">.</span><span class="n">sleep</span><span class="p">(</span><span class="mi">1</span><span class="p">)</span>

<span class="k">def</span> <span class="nf">consumer</span><span class="p">():</span>
    <span class="k">while</span> <span class="bp">True</span><span class="p">:</span>
        <span class="n">n</span> <span class="o">=</span> <span class="n">numbers</span><span class="o">.</span><span class="n">get</span><span class="p">()</span>
        <span class="n">before</span> <span class="o">=</span> <span class="n">time</span><span class="o">.</span><span class="n">time</span><span class="p">()</span>
        <span class="n">primality</span> <span class="o">=</span> <span class="n">is_prime</span><span class="p">(</span><span class="n">n</span><span class="p">)</span>
        <span class="n">elapsed</span> <span class="o">=</span> <span class="n">time</span><span class="o">.</span><span class="n">time</span><span class="p">()</span> <span class="o">-</span> <span class="n">before</span>
        <span class="k">if</span> <span class="n">primality</span><span class="p">:</span>
            <span class="k">print</span> <span class="n">n</span><span class="p">,</span> <span class="s">&quot;is prime&quot;</span>
            <span class="n">conn</span><span class="o">.</span><span class="n">consumer</span><span class="o">.</span><span class="n">record</span><span class="p">(</span><span class="s">&quot;prime&quot;</span><span class="p">,</span> <span class="n">count</span> <span class="o">=</span> <span class="mi">1</span><span class="p">,</span> <span class="n">time</span> <span class="o">=</span> <span class="n">elapsed</span><span class="p">)</span>
        <span class="k">else</span><span class="p">:</span>
            <span class="k">print</span> <span class="n">n</span><span class="p">,</span> <span class="s">&quot;is not prime&quot;</span>
            <span class="n">conn</span><span class="o">.</span><span class="n">consumer</span><span class="o">.</span><span class="n">record</span><span class="p">(</span><span class="s">&quot;composite&quot;</span><span class="p">,</span> <span class="n">count</span> <span class="o">=</span> <span class="mi">1</span><span class="p">,</span> <span class="n">time</span> <span class="o">=</span> <span class="n">elapsed</span><span class="p">)</span>

<span class="k">def</span> <span class="nf">producer</span><span class="p">():</span>
    <span class="k">while</span> <span class="bp">True</span><span class="p">:</span>
        <span class="n">n</span> <span class="o">=</span> <span class="nb">int</span><span class="p">((</span><span class="n">time</span><span class="o">.</span><span class="n">time</span><span class="p">()</span> <span class="o">%</span> <span class="mi">30</span><span class="p">)</span> <span class="o">**</span> <span class="n">normalvariate</span><span class="p">(</span><span class="mi">5</span><span class="p">,</span> <span class="mi">2</span><span class="p">))</span>
        <span class="k">if</span> <span class="n">n</span> <span class="o">&lt;</span> <span class="mi">2</span><span class="p">:</span>
            <span class="n">conn</span><span class="o">.</span><span class="n">producer</span><span class="o">.</span><span class="n">record</span><span class="p">(</span><span class="n">too_small</span> <span class="o">=</span> <span class="mi">1</span><span class="p">)</span>
        <span class="k">elif</span> <span class="n">n</span> <span class="o">&gt;</span> <span class="mi">10</span> <span class="o">**</span> <span class="mi">9</span><span class="p">:</span>
            <span class="n">conn</span><span class="o">.</span><span class="n">producer</span><span class="o">.</span><span class="n">record</span><span class="p">(</span><span class="n">too_big</span> <span class="o">=</span> <span class="mi">1</span><span class="p">)</span>
        <span class="k">else</span><span class="p">:</span>
            <span class="n">conn</span><span class="o">.</span><span class="n">producer</span><span class="o">.</span><span class="n">record</span><span class="p">(</span><span class="n">just_right</span> <span class="o">=</span> <span class="mi">1</span><span class="p">)</span>
            <span class="n">numbers</span><span class="o">.</span><span class="n">put</span><span class="p">(</span><span class="n">n</span><span class="p">)</span>
        <span class="n">time</span><span class="o">.</span><span class="n">sleep</span><span class="p">(</span><span class="mf">0.33</span><span class="p">)</span>

<span class="k">if</span> <span class="n">__name__</span> <span class="o">==</span> <span class="s">&quot;__main__&quot;</span><span class="p">:</span>
    <span class="n">collectd</span><span class="o">.</span><span class="n">start_threads</span><span class="p">()</span>
    <span class="k">for</span> <span class="n">func</span> <span class="ow">in</span> <span class="p">[</span><span class="n">producer</span><span class="p">,</span> <span class="n">consumer</span><span class="p">]:</span>
        <span class="n">t</span> <span class="o">=</span> <span class="n">Thread</span><span class="p">(</span><span class="n">target</span> <span class="o">=</span> <span class="n">func</span><span class="p">)</span>
        <span class="n">t</span><span class="o">.</span><span class="n">daemon</span> <span class="o">=</span> <span class="bp">True</span>
        <span class="n">t</span><span class="o">.</span><span class="n">start</span><span class="p">()</span>
    
    <span class="n">watch_queue</span><span class="p">()</span>
</pre></div>
</div>
<p>Here&#8217;s a list of files generated by this code, along with an explanation of
the counter which each file contains for each time interval:</p>
<ul class="simple">
<li><tt class="docutils literal"><span class="pre">gauge-queue-size.rrd</span></tt>: a snapshot of the size of the numbers queue</li>
<li><tt class="docutils literal"><span class="pre">gauge-producer-too_small.rrd</span></tt>: a count of the random numbers generated by the producer thread which were discarded for being too small</li>
<li><tt class="docutils literal"><span class="pre">gauge-producer-too_big.rrd</span></tt>: a count of the random numbers generated by the producer thread which were discarded for being too large</li>
<li><tt class="docutils literal"><span class="pre">gauge-producer-just_right.rrd</span></tt>: a count of the random numbers generated by the producer thread which were sent to the consumer thread for factoring</li>
<li><tt class="docutils literal"><span class="pre">gauge-consumer-count.rrd</span></tt>: an overall count of the numbers factored by the consumer thread</li>
<li><tt class="docutils literal"><span class="pre">gauge-consumer-composite-count.rrd</span></tt>: a count of the numbers factored by the consumer thread which turned out to be non-prime</li>
<li><tt class="docutils literal"><span class="pre">gauge-consumer-prime-count.rrd</span></tt>: a count of the numbers factored by the consumer thread which turned out to be prime</li>
<li><tt class="docutils literal"><span class="pre">gauge-consumer-time.rrd</span></tt>: the amount of wallclock time elapsed while factoring numbers</li>
<li><tt class="docutils literal"><span class="pre">gauge-consumer-composite-time.rrd</span></tt>: the amount of wallclock time elapsed while factoring numbers which turned out to be non-prime</li>
<li><tt class="docutils literal"><span class="pre">gauge-consumer-prime-time.rrd</span></tt>: the amount of wallclock time elapsed while factoring numbers which turned out to be prime</li>
</ul>
<p>TODO: add graphs to this example to demonstrate what the data looks like</p>
</div>
<div class="section" id="a-utility-for-graphing-rrd-data">
<h1>A Utility for Graphing RRD Data<a class="headerlink" href="#a-utility-for-graphing-rrd-data" title="Permalink to this headline">¶</a></h1>
<p>This is forthcoming; we&#8217;d like a simple script for generating the complex
command-line arguments understood by <tt class="docutils literal"><span class="pre">rrdtool</span> <span class="pre">graph</span></tt> commands.</p>
<p>At some point we may also want a web interface similar to the existing
collectd cgi script which dynamically lets you select and generate graphs,
but with awareness of the semantics of the files generated by this module,
which would allow users to start with a high-level overview and drill-down
into specific data, combine data from different sources into one graph, etc.</p>
</div>


          </div>
        </div>
      </div>
      <div class="sphinxsidebar">
        <div class="sphinxsidebarwrapper">
            <h3><a href="#">Table Of Contents</a></h3>
            <ul>
<li><a class="reference external" href="#">collectd - Send statistics over UDP to collectd servers</a></li>
<li><a class="reference external" href="#installation">Installation</a></li>
<li><a class="reference external" href="#functions-and-classes">Functions and Classes</a></li>
<li><a class="reference external" href="#logging">Logging</a></li>
<li><a class="reference external" href="#a-more-complex-example">A More Complex Example</a></li>
<li><a class="reference external" href="#a-utility-for-graphing-rrd-data">A Utility for Graphing RRD Data</a></li>
</ul>

            <h3>This Page</h3>
            <ul class="this-page-menu">
              <li><a href="_sources/index.txt"
                     rel="nofollow">Show Source</a></li>
            </ul>
          <div id="searchbox" style="display: none">
            <h3>Quick search</h3>
              <form class="search" action="search.html" method="get">
                <input type="text" name="q" size="18" />
                <input type="submit" value="Go" />
                <input type="hidden" name="check_keywords" value="yes" />
                <input type="hidden" name="area" value="default" />
              </form>
              <p class="searchtip" style="font-size: 90%">
              Enter search terms or a module, class or function name.
              </p>
          </div>
          <script type="text/javascript">$('#searchbox').show(0);</script>
        </div>
      </div>
      <div class="clearer"></div>
    </div>
    <div class="related">
      <h3>Navigation</h3>
      <ul>
        <li class="right" style="margin-right: 10px">
          <a href="genindex.html" title="General Index"
             >index</a></li>
        <li><a href="#">collectd v1.0 documentation</a> &raquo;</li> 
      </ul>
    </div>
    <div class="footer">
      &copy; Copyright 2010, Eli Courtwright.
      Created using <a href="http://sphinx.pocoo.org/">Sphinx</a> 0.6.4.
    </div>
  </body>
</html>